package screen;

import framework.Key;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.KeyEvent;

import framework.Util;
import framework.Screen;
import game.Global;
import game.Nave;
import game.Tiro;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;

public class GameLevelScreen extends Screen {

    private List<Image> title;
    private boolean re;

    public GameLevelScreen() {
        re = false;
        title = new ArrayList<Image>();
        title.add(Util.loadImage(Global.IMG_GAME_LEVEL1));
        title.add(Util.loadImage(Global.IMG_GAME_LEVEL2));
        title.add(Util.loadImage(Global.IMG_GAME_LEVEL3));
        title.add(Util.loadImage(Global.IMG_GAME_LEVEL4));
        title.add(Util.loadImage(Global.IMG_GAME_LEVEL5));
        title.add(Util.loadImage(Global.IMG_GAME_LEVEL6));
        title.add(Util.loadImage(Global.IMG_GAME_LEVEL7));
        title.add(Util.loadImage(Global.IMG_GAME_LEVEL8));
        title.add(Util.loadImage(Global.IMG_GAME_LEVEL9));
        title.add(Util.loadImage(Global.IMG_GAME_LEVEL10));
        title.add(Util.loadImage(Global.IMG_GAME_WIN));
        title.add(Util.loadImage(Global.IMG_GAME_LEVELRE));


        if (Global.naveAtiva.getPower() <= 0) {
            Global.naveAtiva = new Nave();
            Global.naveAtiva.addMunicao(Tiro.TYPE_6, 300);
            re = true;
        } else if (Global.level <= 10) {
            Global.updateLevel();
        }


//        Global.pontuacao+=Global.pontuacaoFase;
//
//        Global.navesPorLegiao+=2;
//        Global.indiceBombas=(int) (Global.indiceBombas * 0.75);
//        Global.numeroLegioes+=2;
    }

    public void paint(Graphics g) {
        if (re) {
            g.drawImage(title.get(title.size() - 1), 0, 0, null);
        } else {
            g.drawImage(title.get(Global.level - 1), 0, 0, null);
        }

        if(Global.level==11){
            g.setColor(Color.WHITE);
            g.drawString("SUA PONTUAÇÃO: "+Global.pontuacao, 300, 300);
        }

    }

    public void update() {


        if (Key.isDown(KeyEvent.VK_ENTER) || Key.isDown(KeyEvent.VK_S)) {
            if (Global.level >= 11) {
                Screen.setCurrentScreen(new CreditosScreen());
                Global.zerar();
            } else // iniciar jogo
            {
                Screen.setCurrentScreen(new GameScreen());
            }




        } else if (Key.isDown(KeyEvent.VK_ESCAPE)) {
            // sair do jogo
            Screen.setCurrentScreen(new TitleScreen());
        }
    }
}
